
<?php 
include_once('conn.php');
//include_once('login_check.php');

//加密解密函数
include_once("function/encode_inc.php");

//实例化对象
include_once('class/db.class.php');		//引入数据库操作类
$db	=	new	db();








//添加项目
if($_REQUEST['action']=='add'){

	//加载模版
	include_once('templeta/projectAdd.php');

}


//添加项目
if($_REQUEST['action']=='addProject'){
	
		//检测
		noEmptyCk('pname','必须填写项目名称');
		noEmptyCk('description','必须填写项目描述');
		noEmptyCk('need','必须填写项目需求');
		noEmptyCk('cname','必须填写联系人');
		noEmptyCk('contact','必须填写联系方式');
		noEmptyCk('address','必须填写联系地址');
		
		//uid
		if(!empty($GLOBALS['user_id'])){
			$uid	=	$GLOBALS['user_id'];
		}else{
			$uid	= 0;
		}
		
		$data	=	array(
							'pname'=>trim($_POST['pname']),
							'description'=>addslashes($_POST['description']),
							'need'=>addslashes($_POST['need']),
							'cname'=>trim($_POST['cname']),
							'contact'=>trim($_POST['contact']),
							'address'=>trim($_POST['address']),
							'add_uid'=>$uid,
							'add_time'=>date("Y-m-d H:i:s")
							);
		
		$result	=	$db->insert('project',$data);
		if(!$result){
				echo "<script>alert('服务器忙碌，请再次尝试');history.go(-1);</script>";
				die();
		}else{
				echo "<script>alert('添加需求信息成功，现在跳转回需求资料页面列表');location.href='/project.php?action=list';</script>";
				die();
		}
		
		
		
}















//非空提交检测
function noEmptyCk($id,$tips){
	if(empty($_REQUEST[$id])){
		echo "<script>alert('$tips');history.go(-1);</script>";	
		die();
	}
}

?> 